<?php
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EnhablingPlugin
 *
 * @author JeyDotC
 * @export Plugins
 */
class EnhablingPlugin extends UnderscorePlugin implements ReplaceTask {
    
    private $action;

    public function replaceTask() {
        return $this->action;
    }

    public function willReplaceTask($task) {
        $module = $this->getModule()->getName();
        
        $modulesConfig = ModulesContext::instance()->getConfig()->get("Modules");
        
        if(array_key_exists($module, $modulesConfig)){
            $moduleConfig = $modulesConfig[$module];
            if(array_key_exists("disabled", $moduleConfig)){
                $this->action = isset ($moduleConfig["action"]) ? $moduleConfig["action"] : "";
            }
        }
        
        $willReplace = !empty ($this->action);
        return $willReplace;
    }
}

?>
